package com.heim.test;

import cn.hutool.http.Header;
import cn.hutool.http.HttpRequest;

import java.util.HashMap;
import java.util.Map;

public class SMSDemo {
    public static void main(String[] args) {

        //使用你自己的appCode，从https://market.console.aliyun.com/imageconsole/index.htm?#/bizlist?_k=r5f9m0查找
        String appCode = "58e101e038dc407a9f4c79f6c47432d9";
        //接收验证码的手机号
        String mobile = "13466486323";
        //短信验证码
        String code = "888888";


        /***以下内容固定，不要改变***/
        String apiUrl = "https://gyytz.market.alicloudapi.com/sms/smsSend";
        Map<String, Object> formMap = new HashMap<String, Object>();
        formMap.put("mobile", mobile);
        formMap.put("param", "**code**:"+code+",**minute**:5");
        //使用默认smsSignId即可
        formMap.put("smsSignId", "2e65b1bb3d054466b82f0c9d125465e2");
        //使用默认templateId即可
        formMap.put("templateId", "908e94ccf08b4476ba6c876d13f084ad");
        try {
            String result = HttpRequest.post(apiUrl)
                     //头信息，多个头信息多次调用此方法即可
                    .header(Header.AUTHORIZATION, "APPCODE " + appCode)
                    .form(formMap)//表单内容
                    .timeout(20000)//超时，毫秒
                    .execute().body();
            System.out.println(result);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}